import time
from collections import Iterable,Iterator

class Classmate(object):
    def __init__(self):
        self.names=list()
        self.current_num=0

    def add(self,name):
        self.names.append(name)

    def __iter__(self):
        return self

    def __next__(self):
        if self.current_num<len(self.names):
            ret=self.names[self.current_num]
            self.current_num+=1
            return ret
        else:
            raise StopIteration

if __name__ == '__main__':
    classmate=Classmate()
    classmate.add('AK')
    classmate.add('AKW')
    classmate.add('AKM')

    for name in classmate:
        print(name)
    print('判断classmate是否为可迭代对象:', isinstance(classmate, Iterable))
    classmate_iterator = iter(classmate)
    print('判断classmate_iterator是否为迭代器', isinstance(classmate_iterator, Iterator))
